(function(doc, win) {
    var docEl = doc.documentElement,
        resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
        recalc = function() {
            //document.body.style.maxWidth = 320 / 480 * window.innerHeight + 'px'
            var clientWidth = Math.min(320 / 480 * window.innerHeight, docEl.clientWidth);
            if (!clientWidth) return;
            docEl.style.fontSize = 20 * (clientWidth / 375) + 'px';
        };
    if (!doc.addEventListener) return;
    win.addEventListener(resizeEvt, recalc, false);
    doc.addEventListener('DOMContentLoaded', recalc, false);

    // win.addEventListener(resizeEvt, hackFont, false);    
    // doc.addEventListener('DOMContentLoaded', hackFont, false);   
})(document, window);

function hackFont() {
    if (document.body.clientWidth <= 320 || document.documentElement.clientWidth <= 320 || document.body.offsetWidth <= 320) {
        console.log(document.body.clientWidth);
        document.documentElement.style.fontSize = '13px';
    }
}